/*
 * $Id: Variable.java,v 1.1 2007-01-29 17:00:56 klose Exp $
 */
package de.fanuffel.generic;

public class Variable<Type> {

  private Type value;

  public Variable() {
    this.value = null;
  }

  public Variable(final Type t) {
    value = t;
  }

  public boolean match(Variable<Type> t) {
    if (value == null) {
      value = t.value;
      return true;
    }
    return t.value == this.value;
  }

  public boolean unify(Variable<Type> t) {
    return this.match(t) || t.match(this);
  }

  public Type value() {
    return value;
  }

}